/**
 * 
 */
package com.ubo.java.model;

import com.ubo.transform.java.IJavaGenerable;
import com.ubo.transform.java.IJavaVisitor;

/**
 * @author saludegu
 * 
 */
public class PackageModel implements IJavaGenerable {

	/**
	 * Set des sous-packages du packages.
	 */
	protected PackageModel mFatherPackage;

	/**
	 * Nom du package.
	 */
	protected final String mPackageName;

	/**
	 * 
	 * Constructor
	 * 
	 * @param packageName
	 */
	public PackageModel(String packageName) {
		mPackageName = packageName;
	}

	/**
	 * @return the mSubPackages
	 */
	public PackageModel getFatherPackage() {
		return mFatherPackage;
	}

	/**
	 * @param mFatherPackage
	 */
	public void setmFatherPackage(PackageModel mFatherPackage) {
		this.mFatherPackage = mFatherPackage;
	}

	/**
	 * @return the mPackageName
	 */
	public String getPackageName() {
		return mPackageName;
	}

	/**
	 * @see com.ubo.transform.java.IJavaGenerable#generate(com.ubo.transform.java.IJavaVisitor)
	 */
	@Override
	public void generate(IJavaVisitor<?> generator) {
		generator.generate(this);
	}

	/**
	 * @return the mFatherPackage
	 */
	public StringBuffer printPath() {
		StringBuffer buffer = new StringBuffer();
		if (mFatherPackage != null) {
			buffer.append(mFatherPackage.printPath().toString() + ".");
			buffer.deleteCharAt(buffer.length() - 1);
		}
		buffer.append(mPackageName);
		return buffer;
	}
}
